package com.traffic.fuwu.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.traffic.fuwu.dao.CarryMapper;
import com.traffic.fuwu.mybatis.pojo.Carry;
import com.traffic.fuwu.mybatis.pojo.CarryExample;
import com.traffic.fuwu.service.CarryService;
@Service
public class CarryServiceImpl implements CarryService{
    @Autowired
    private CarryMapper carryMapper;
	@Override
	public Carry selectPrice(String carryCode) {
		CarryExample example = new CarryExample();
		example.or().andCarryCodeEqualTo(carryCode);
		List<Carry> list =carryMapper.selectByExample(example);
		if(list != null && list.size() != 0){
			Carry carry = list.get(0);
			return carry;
		}
		return null;
	}
	@Override
	public List<Carry> getCarryList(String carryCode, String lineCode,
			String lineName, String deptName, String appKey, int startRow,
			int pageSize) {
		List<Carry> sb = new ArrayList<>();
		try {
		sb=carryMapper.getCarryList(carryCode, lineCode, lineName, deptName, appKey, startRow, pageSize);
		} catch (Exception e) {
		e.printStackTrace();
		}
		return sb;
	}
	
	@Override
	public int getCarryCount(String carryCode, String lineCode, String lineName,
			String deptName, String appKey) {
		int count = 0;
		try {
	        count = carryMapper.getCarryCount(carryCode, lineCode, lineName, deptName, appKey);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return count;
	}
	@Override
	public Carry getCarry(String carryCode,String appKey) {
		CarryExample example = new CarryExample();
		example.or().andCarryCodeEqualTo(carryCode).andAppKeyEqualTo(appKey);
		List<Carry> list = carryMapper.selectByExample(example);
		if(list != null && list.size() != 0){
			Carry carry = list.get(0);
			return carry;
		}
		return null;
	}

}
